Make sure test directory exists
authorTamir Duberstein <tamird@gmail.com>
Mon, 23 Mar 2015 20:53:28 +0000 (13:53 -0700)
committerTamir Duberstein <tamird@gmail.com>
Mon, 23 Mar 2015 21:00:01 +0000 (14:00 -0700)
tests/support/paths.rs

index 491990c0a0ac34f348fb947770120b46d4761ae2..9abab9a193577ca56e6bca08ed5d30c1f6d8a9b1 100644 (file)
@@ -3,6 +3,7 @@ use std::fs;
 use std::io::prelude::*;
 use std::io::{self, ErrorKind};
 use std::path::{Path, PathBuf};
+use std::sync::{Once, ONCE_INIT};
 use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
 
 static CARGO_INTEGRATION_TEST_DIR : &'static str = "cit";
@@ -101,6 +102,10 @@ impl CargoPathExt for Path {
 /// Ensure required test directories exist and are empty
 pub fn setup() {
     debug!("path setup; root={}; home={}", root().display(), home().display());
+    static INIT: Once = ONCE_INIT;
+    INIT.call_once(|| {
+        root().parent().unwrap().mkdir_p().unwrap();
+    });
     root().rm_rf().unwrap();
     home().mkdir_p().unwrap();
 }